# $Id$
# Maintainer: Thomas Bächler <thomas@archlinux.org>

pkgname=easy-rsa
pkgver=3.0.3
pkgrel=2
pkgdesc='Simple shell based CA utility'
arch=('any')
url='https://github.com/OpenVPN/easy-rsa'
depends=('openssl' 'sh')
license=('custom')
backup=('etc/easy-rsa/openssl-1.0.cnf'
	'etc/easy-rsa/vars')
validpgpkeys=(
	'65FF3F24AA08E882CB444C94D731D97A606FD463'	# Josh Cepek <josh.cepek@usa.net>
	'6F4056821152F03B6B24F2FCF8489F839D7367F3')	# Eric Crist <ecrist@secure-computing.net>
source=("https://github.com/OpenVPN/easy-rsa/releases/download/v${pkgver}/EasyRSA-${pkgver}.tgz"{,.sig}
        '0001-fix-paths.patch')
sha256sums=('fb239d67f4bd09f817b0025450d422ed7ae3ee93af737c57d4acd8fdb646079e'
            'SKIP'
            'c8287a6c3e79c36dcadbf2bd11b0fe2698f2ec8d6824b0dc22783ade36b8d2f6')

prepare() {
	cd EasyRSA-${pkgver}/

	# fix output of help command, we have it in PATH
	sed -i 's|./easyrsa|easyrsa|' easyrsa

	# fix paths
	patch -Np1 < "${srcdir}"/0001-fix-paths.patch
}

package() {
	cd EasyRSA-${pkgver}/

	install -D -m0755 easyrsa "${pkgdir}"/usr/bin/easyrsa

	install -D -m0644 openssl-1.0.cnf "${pkgdir}"/etc/easy-rsa/openssl-1.0.cnf
	install -D -m0644 vars.example "${pkgdir}"/etc/easy-rsa/vars
	install -d -m0755 "${pkgdir}"/etc/easy-rsa/x509-types/
	install -m0644 x509-types/* "${pkgdir}"/etc/easy-rsa/x509-types/

	install -d -m0755  ${pkgdir}/usr/share/doc/easy-rsa/
	install -m0644 doc/* ChangeLog ${pkgdir}/usr/share/doc/easy-rsa/

	install -D -m0644 COPYING.md ${pkgdir}/usr/share/licenses/easy-rsa/COPYING
}

